home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!news
- From: philma@ix.netcom.com(Phil Majtan)
- Newsgroups: comp.lang.c
- Subject: Re: How do the functions in <time.h> work?
- Date: 20 Apr 1996 21:54:22 GMT
- Organization: Netcom
- Message-ID: <4lbmee$hrg@dfw-ixnews1.ix.netcom.com>
- References: <317653DA.5066@ix.netcom.com>
- NNTP-Posting-Host: det-mi4-18.ix.netcom.com
- X-NETCOM-Date: Sat Apr 20 4:54:22 PM CDT 1996
-
- In <317653DA.5066@ix.netcom.com> Jane Harper <jharper@ix.netcom.com>
- writes:
- >
- >This is sort of a homework question, so flame away if you must ...
- >
- >...but I'm attempting to write a bit of code to access the system time
-
- >and when I call ctime() it returns January, 2014 (!!!!) How does
- ctime
- >work (or any of the fx in <time.h> for that matter, since they're all
- >connected)? What are some possible reasons for this bogus return?
- >
- >TIA
- >
- >Jane Harper
-
- In my compiler (BCC), the ctime function is passed a pointer to a
- time_t variable. If you are passing it someting else, it may be
- interpreting garbage. It may not be getting a pointer...
- Try something like:
-
- {
- time_t timevar;
-
- {some code to set the time, like time(&timevar) }
-
- printf ("%s",ctime(&timevar));
-
- }
-
- Phil
-
-